package com.fancy.mobileschool.service;

import android.util.Log;

import com.fancy.mobileschool.entity.Person;

import okhttp3.FormBody;
import okhttp3.RequestBody;

/**
 * Created by Jackie on 2017/12/8.
 */

public class UserService {

    private static final String baseURL = URLConfig.baseUrl + "user/";

    public Person signIn(String id, String password) {
        String url = baseURL + "signIn.do";
        FormBody body = new FormBody.Builder()
                .add("id", id)
                .add("password", password).build();
        Person person = OKHttpBase.fromJsonByPost(url, body, Person.class);
        return person;
    }

    public Person signUp(Person person) {
        String url = baseURL + "signUp.do";
        Log.i("wode", person.toString());
        FormBody body = new FormBody.Builder()
                .add("id", person.id)
                .add("password", person.password)
                .add("type", person.type)
                .add("name", person.name).build();

        Person result = OKHttpBase.fromJsonByPost(url, body, Person.class);
        return result;
    }
}
